﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTO;

namespace DAO
{
    public class NhienLieuDao
    {
        public int LayMa()
        {
            DoixeDataContext DX = new DoixeDataContext();

            int Lable;
            Lable = 0;
            int MA = 0;
            while (Lable == 0)
            {
                IEnumerable<CAPNHIENLIEU> xDto;
                xDto = from x in DX.CAPNHIENLIEUs where x.MaPhieu == MA select x;
                if (xDto.Count() != 0)
                {
                    MA++;
                }
                else
                {
                    Lable = 1;
                }
            }
            return MA;
        }
        public void  CapNhienLieu(CAPNHIENLIEU NL)
        {
            DoixeDataContext DX = new DoixeDataContext();
            DX.CAPNHIENLIEUs.InsertOnSubmit(NL);
            DX.SubmitChanges();
        }
        public IEnumerable<CAPNHIENLIEU> CapNhienLieu()
        {
            DoixeDataContext DX = new DoixeDataContext();
            return DX.CAPNHIENLIEUs;
        }
    }
}
